import { type Knowledge, type KnowledgeList } from "@/types/consult";
import request from "@/utils/request";

const DICT_BASE_URL = "/knowledge";

const KnowledgeAPI = {
  /**
   * 获取文章分页列表
   *
   * @param queryParams 查询参数
   * @returns 文章分页结果
   */
  getKnowledge(queryParams: KnowledgePageQuery) {
    return request<KnowledgeList | undefined>({
      url: DICT_BASE_URL,
      method: "GET",
      data: queryParams,
    });
  },
  /**
   * 获取文章详情数据
   *
   * @param id 文章ID
   * @returns 文章详情数据
   */
  getKnowledgeInfo(id: string) {
    return request<Knowledge | undefined>({
      url: DICT_BASE_URL + "/" + id,
      method: "GET",
    });
  },
};

export default KnowledgeAPI;

export interface KnowledgePageQuery {
  pageNum: number;
  likeFlag: number;
}
